# _*_ coding: UTF-8 _*_
# @Time     : 2021/10/22 15:22
# @Author   : Gong Yangyi
# @Site     : http://www.hzdledu.cn/
# @File     : homework3.py
# @Software : PyCharm

# 4.打印以下图形
# * * * * *
# * * * *
# * * *
# * *
# *
for i in range(5, 0, -1):  # 循环的嵌套
    for j in range(i):
        print('*', end=' ')
    print()
# 5.打印以下图形
# * * * * *
#   * * * *
#     * * *
#       * *
#         *
for i in range(5):
    for j in range(0, i):
        print(' ', end=' ')

    for j in range(i, 5):
        print('*', end=' ')
    print()
# 6.打印以下图形
#         *
#       * *
#     * * *
#   * * * *
# * * * * *
for i in range(1, 6):
    for j in range(i, 5):
        print(' ', end=' ')
    for j in range(i):
        print('*', end=' ')
    print()

# 7.打印以下图形
#       *
#     * * *
#   * * * * *
# * * * * * * *
#   * * * * *
#     * * *
#       *
num = 10
for i in range(num // 2 + 1):
    for j in range(num // 2 + 1 - i - 1):
        print(' ', end=' ')
    for k in range(2 * i + 1):
        print('*', end=' ')
    print()
for i in range(num // 2):
    for j in range(i + 1):
        print(' ', end=' ')
    for k in range(num // 2 * 2 - 2 * (i + 1) + 1):
        print('*', end=' ')
    print()

# 8. 猜数字游戏，增加游戏次数限制，最多只能猜5次。如果5次都没猜正确，给出提示，游戏结束
import random

num = random.randint(1, 10)
print(num)
i = 0
while i < 3:
    n = int(input('请输入要猜的数字（1-10）：'))
    if num == n:
       print('猜对了')
       break
    elif n > num:
        print('大了')
    elif n < num:
        print('小了')
    else:
        pass
    i += 1
